<!DOCTYPE html>
<html>
<head>
<title>需求信息页面</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript">
	var path = window.document.location.href;
	var pathName = window.document.location.pathname;
	var hostPath = path.substring(0, path.indexOf(pathName));
	var projectName = pathName
			.substring(0, pathName.substr(1).indexOf("/") + 1);
	document
			.write('<scr' + 'ipt src="' + projectName + '/js/html/header.js"></scr'+'ipt>');
</script>
</head>
<body>
	<div id="dlg-buttons">
		<a href="javascript:dowork()" class="easyui-linkbutton"
			iconCls="icon-ok">提交</a>
	</div>
	<div id="dlgEdit" class="dlgEdit" closed="true"
		style="width: 730px; height: 380px; padding: 10px 10px;"
		buttons="#dlg-buttons">
		<form method="post" id="fm">
			<table cellspacing="8px;">
				<td><input id="id" name="id" style="display: none"></td>
				<tr>
					<td>业务编号</td>
					<td><input id="businessKey" name="businessKey"
						class="easyui-validatebox" required="true">&nbsp;</td>
				</tr>
				<tr>
					<td>流程实例号</td>
					<td><input id='procInstId' name='procInstId'
						class='easyui-validatebox' required='true'>&nbsp; <span
						style='color: red'>*</span></td>
				</tr>
				<tr>
					<td>任务号</td>
					<td><input id='taskId' name='taskId'
						class='easyui-validatebox' required='true'>&nbsp; <span
						style='color: red'>*</span></td>
				</tr>
				<tr>
					<td>需求编号</td>
					<td><input id="requireNo" name="requireNo"
						class="easyui-validatebox" required="true">&nbsp; <span
						style="color: red">*</span></td>
				</tr>
				<tr>
					<td>需求名称</td>
					<td><input id="requireName" name="requireName"
						class="easyui-validatebox" required="true">&nbsp; <span
						style="color: red">*</span></td>
				</tr>
				<tr>
					<td>需求类型</td>
					<td><input id="requireType" name="requireType"
						class="easyui-combobox" required="true">&nbsp; <span
						style="color: red">*</span></td>
				</tr>
				<tr>
					<td>是否项目</td>
					<td><input id="isProject" name="isProject"
						class="easyui-combobox" required="true">&nbsp; <span
						style="color: red">*</span></td>
				</tr>
				<tr>
					<td>预算金额(万)</td>
					<td><input id="budget" name="budget"
						class="easyui-validatebox" required="true">&nbsp; <span
						style="color: red">*</span></td>
				</tr>
				<tr>
					<td>需求提出部门</td>
					<td><input id="department" name="department"
						class="easyui-combobox" required="true">&nbsp; <span
						style="color: red">*</span></td>
				</tr>
				<tr>
					<td>需求提出三级部门</td>
					<td><input id="subdepart" name="subdepart"
						class="easyui-validatebox"></td>
				</tr>
				<tr>
					<td>项目经理</td>
					<td><input id="pm" name="pm" class="easyui-validatebox"
						required="true">&nbsp; <span style="color: red">*</span>
					</td>
				</tr>
				<tr>
					<td>项目经理所在部门</td>
					<td><input id="pmDepartment" name="pmDepartment"
						class="easyui-combobox" required="true">&nbsp; <span
						style="color: red">*</span></td>
				</tr>
				<tr>
					<td>涉及改造的主系统</td>
					<td><input id="mainSystem" name="mainSystem"
						class="easyui-validatebox"></td>
				</tr>
				<tr>
					<td>审批意见</td>
					<td><input id="comments" name="comments"
						class="easyui-combobox"></td>
				</tr>
				<tr>
					<td>当前处理人</td>
					<td><input id="currentHandler" name="currentHandler"
						class="easyui-validatebox" required="true">&nbsp; <span
						style="color: red">*</span></td>
				</tr>
				<tr>
					<td>下一个处理人</td>
					<td><input id="nextHandler" name="nextHandler"
						class="easyui-validatebox" required="true">&nbsp; <span
						style="color: red">*</span></td>
				</tr>
				<tr>
					<td>上一个处理人</td>
					<td><input id="lastHandler" name="lastHandler"
						class="easyui-validatebox" required="true">&nbsp; <span
						style="color: red">*</span> ></td>
				</tr>
			</table>
		</form>
	</div>
	<div id="dlg-Details" class="easyui-window" closed="true"
		style="width: 730px; height: 280px; padding: 10px 10px;"></div>
	<script>
		$(document).ready(function() {
			var procInstId = getParam('procInstId');
			var taskId = getParam('taskId');
			var processkey = getParam('processkey');
			var taskDefKey = getParam('taskDefKey');
			var businessKey = getParam('businessKey');
			$('#businessKey').val(businessKey);
			$('#procInstId').val(procInstId);
			$('#taskId').val(taskId);
			$('#processkey').val(processkey);
			getProjectInfo(businessKey);
		});

		//获取URL参数
		function getParam(name) {
			var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
			var r = window.location.search.substr(1).match(reg);
			if (r != null)
				return decodeURI(r[2]);
			return null;
		}

		function getProjectInfo(businessKey) {
			$.ajax({
				type : "POST",
				async : false,
				url : projectName + "/projectinfo/projectInfoQuery.do",
				data : {
					'page' : 1,
					'rows' : 1,
					'id' : businessKey
				},
				dataType : "json",
				success : function(data) {
					if (!data.success) {
						alert(data.errorMsg);
						return;
					}
					if (data != null) {
						console.log(data);
						$("#fm").form("load", data.rows[0]);
					}
				},
				error : function(err, status) {
					errorMsgAlert(err);
				}
			});

		}

		function commit() {
			var selectedRows = $("#dg").datagrid("getSelections");
			if (selectedRows.length != 1) {
				$.messager.alert("系统提示", "请选择一条要编辑的数据！");
				return;
			}
			var row = selectedRows[0];
			alert(row)

			$.messager.progress();
			$.ajax({
				type : "POST",
				url : projectName + initd.commitDataURL,
				data : row,
				dataType : "json",
				success : function(data) {
					if (data != null) {
						alert('提交成功');
						$.messager.progress("close");
					}
				}
			});
		}

		function dowork() {
			$.messager.progress();
			$.ajax({
				type : "POST",
				dataType : "json",
				url : projectName + "/workflow/task/dowork",
				data : $("#fm input").serialize(),
				beforeSend : function() {
					var isValid = $("#fm").form("validate")
					if (!isValid) {
						$.messager.progress("close");
						$.messager.alert("系统提示", "表单验证不通过！");
					}
					return isValid;
				},
				success : function(result) {
					$.messager.progress("close");
					if (result.success) {
						alert("提交成功！"); //阻塞方式提示，否则窗口关闭提示框也一起被关闭 
						//$.messager.alert("系统提示", "提交成功！");
						debugger;
						resetFromValue();
						$("#win").dialog("close");
					} else {
						if (!jQuery.isEmptyObject(result.errorMsg)) {
							$.messager.alert("系统错误", result.errorMsg);
						} else {
							$.messager.alert("系统错误", result);
						}
						return;
					}
				},
				error : function(err, status) {
					errorMsgAlert(err);
					$.messager.progress("close");
				}
			});
		}
	</script>
</body>
</html>
